#include <stdio.h>
#include <math.h>

int main()
{
	int N = 0;
	int n = 0;
	int arr[10000] = { 0 };
	int i = 0;
	int index = 0;
	scanf("%d", &N);
	n = (int)pow(2.0, (double)N);
	for (i=0; i<n; i++)
	{
		scanf("%d", &arr[i]);
		if (0 == arr[i])
		{
			index = i;
		}
	} 
	printf("%d", index);
	return 0;
}

